local gamelib = require "club.threecard.gamelib"
local game = require "club.threecard.bjracing"

local settlement = gamelib.ui.activity()

local log = gamelib.logging.get("settlement")

function settlement:ctor()
    self.res = "club.threecard.bjracing/ui/settlement.b:settlement"

    self.rank_list = game.require("gameui.settlement.rank_list").new();
end

function settlement:load()
    self.rank_list:load();

    self:super("load");
    self.rank_list:set_parent(self.root, false);
end

function settlement:on_injected(bind)
    bind("button.click", self.btn_exit, self.exit_ivk);
end

function settlement:on_set_visibility()
    local data = game.store.ingame.state.settlement;
    if not data then
        self.visible = false;
    end

    self:super("on_set_visibility");
    if not self.gameobject then
        return;
    end

    if not self.visible then
        return;
    end

    local data = game.store.ingame.state.settlement;
    if not data then
        return;
    end

    self.rank_list.list:fill(data.top);
end

function settlement:exit_ivk()
   self:hide(); 
end

return settlement